package java67_adv9;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;

public class ReceiveFile {

	public static void main(String[] args) {
		try {
			Socket s = new Socket("192.168.1.146", 9999);
			// Socket s = new Socket("47.93.151.29", 9999);
			InputStream in = s.getInputStream();
			// OutputStream out = s.getOutputStream();
			FileOutputStream fout = new FileOutputStream("e:/1.png");
			int ch;
			while ((ch = in.read()) != -1) {
				fout.write(ch);
			}
			fout.flush();
			fout.close();
			s.close();
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
